package com.sunlands.qdcy.tongzhuo.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.sunlands.qdcy.tongzhuo.model.UserDiaryReplyDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

import javax.persistence.Id;
import java.util.Date;
import java.util.Objects;

/**
 * @date 2019/5/2914:21
 */
@Data
@JsonSerialize
@ApiModel(value = "消息回复列表")
@Builder
public class MessageReplyVO {

    @Id
    @ApiModelProperty(value = "评论id")
    private Long id;

    @ApiModelProperty(value = "日记id")
    private Long diaryId;

//    @ApiModelProperty(value = "日记图片内容，多个逗号分隔")
//    private String imgUrls;

    @ApiModelProperty(value = "回复用户id")
    private Long replyUserId;

    @ApiModelProperty(value = "回复用户昵称")
    private String replyUserName;

    @ApiModelProperty(value = "回复用户头像")
    private String replyUserAvatarUrl;

    @ApiModelProperty(value = "回复内容")
    private String replyContent;

    @ApiModelProperty(value = "被回复用户id")
    private Long replyedUserId;

    @ApiModelProperty(value = "被回复内容")
    private String replyedContent;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "是否是作者")
    private Boolean author;

    @ApiModelProperty(value = "1:日记的回复，2:评论的回复，3:回复的回复")
    private Integer type;

    public static MessageReplyVO from(UserDiaryReplyDO userDiaryReply) {
        return Objects.isNull(userDiaryReply) ? null: MessageReplyVO.builder()
                .id(userDiaryReply.getId())
                .diaryId(userDiaryReply.getDiaryId())
                .replyContent(userDiaryReply.getReplyContent())
                .replyUserId(userDiaryReply.getReplyUserId())
                .replyedUserId(userDiaryReply.getReplyUserId())
                .createTime(userDiaryReply.getCreateTime())
                .type(userDiaryReply.getType())
                .build();
    }

}
